package ch.ethz.inf.vs.sunspot.drivercore;

/**
 * Helper class to encode the color information of a single LED
 * 
 * @author Simon Mayer, ETH Zurich
 *
 */
public class LedColor {
	private int red;
	private int green;
	private int blue;
	
	/**
	 * Create a new LedColor object and initialize it with 0s
	 */
	public LedColor() {
		this.red = 0;
		this.green = 0;
		this.blue = 0;
	}
	
	/**
	 * Create a new LedColor object and initialize it with the given numbers
	 * @param red
	 * @param green
	 * @param blue
	 */
	public LedColor(int red, int green, int blue) {
		this.red = red;
		this.green = green;
		this.blue = blue;
	}
	
	/**
	 * Create a new LedColor object and initialize it with the numbers passed as an int array
	 * @param red
	 * @param green
	 * @param blue
	 */
	public LedColor(int [] colors) {
		this.red = colors[0];
		this.green = colors[1];
		this.blue = colors[2];
	}
	
	// GETTERS and SETTERS
	
	/**
	 * Get the colors of this LED as an int array
	 */
	public int [] getAllColors() {
		return new int [] { this.getRed(), this.getGreen(), this.getBlue() };
	}
	
	public int getRed() {
		return red;
	}
	
	public void setRed(int newRed) {
		if (newRed > 255) newRed = 255;
		if (newRed < 0) newRed = 0;
		this.red = newRed;
	}
	
	public int getGreen() {
		return green;
	}
	
	public void setGreen(int newGreen) {
		if (newGreen > 255) newGreen = 255;
		if (newGreen < 0) newGreen = 0;
		this.green = newGreen;
	}
	
	public int getBlue() {
		return blue;
	}
	
	public void setBlue(int newBlue) {
		if (newBlue > 255) newBlue = 255;
		if (newBlue < 0) newBlue = 0;
		this.blue = newBlue;
	}
}